package com.zxq.ruoyi.channel;


import com.zxq.exchange.EFrame;
import com.zxq.exchange.ExchangeDTO;
import com.zxq.exchange.observer.INotifyPlatform;
import com.zxq.exchange.observer.NotifyPlatformRegister;
import com.zxq.frame.msg.NotifyPlatformFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
@Slf4j
public class TcpMessageChannel implements INotifyPlatform {



    @PostConstruct
    public void initRegister() {
        NotifyPlatformRegister.getInstance(EFrame.modbus).registerNotify(this);
        NotifyPlatformRegister.getInstance(EFrame.dlt645).registerNotify(this);
        NotifyPlatformRegister.getInstance(EFrame.jt808).registerNotify(this);
        NotifyPlatformRegister.getInstance(EFrame.iec_104).registerNotify(this);
        NotifyPlatformRegister.getInstance(EFrame.sf_register).registerNotify(this);
    }



    @Override
    public void notifyPlatform(ExchangeDTO exchangeDTO) {
        NotifyPlatformFactory.getInstance().create(exchangeDTO.getFrame()).notifyPlatform(exchangeDTO);
    }


}
